#include "SR04.h"

unsigned char  Ultra_MeaCnt;    //操作次数
 
 
//===============================================????
void SR04_GetData(void)
{
	if(Ultra_MeaCnt!=0)return ;
	//---Set High level at GPIO:Trig---//
    TRIG_H;
    delay_us(30);
	//---Set Low level at GPIO:Trig---//
    TRIG_L;
	Ultra_MeaCnt++;
	//---Choose Capture channl---//
	__HAL_TIM_SET_CAPTUREPOLARITY(&htim3, TIM_CHANNEL_1, TIM_INPUTCHANNELPOLARITY_RISING);//配置要捕获波形:上升沿
	HAL_TIM_IC_Start_IT(&htim3, TIM_CHANNEL_1);	//开启TIM4——Channl3的中断				
}
 
 
//===============================================us延时
void delay_us(uint32_t us)//主频72M
{
    uint32_t delay = (HAL_RCC_GetHCLKFreq() / 4000000 * us);
    while (delay--)
	{
		;
	}
}
//---获取步骤号---//
unsigned char Ultra_GetProcess()
{
	return Ultra_MeaCnt;
}
//---设定步骤号---//
void Ultra_SetProcess(unsigned char num)
{
	Ultra_MeaCnt = num;
}
//---步骤号加num---//
void Ultra_AddProcess(unsigned char add_num)
{
	Ultra_MeaCnt+=add_num;
}
